<?php

require "include/template_manager.inc.php";
require_once 'include/language_manager.inc.php';
Language_Manager::getInstance();

$meta["title"] = L::meta_authors_title;
$meta["description"] = L::meta_authors_description;
$meta["keywords"] = L::meta_authors_keywords;

$myTemplate = new Template_Manager('noi', null, true, 1,$meta);
$query = "select `a`.`id` AS `id`,concat(`a`.`nome`,' ',`a`.`cognome`) AS `nomecompleto`,`a`.`nome` AS `nome`,`a`.`cognome` AS `cognome`,`a`.`email` AS `email`,`a`.`telefono` AS `telefono`,`a`.`skype` AS `skype`,`a`.`facebook` AS `facebook`,`a`.`twitter` AS `twitter`,`i`.`descrizione` AS `descrizione`,`i`.`descrizione_en` AS `descrizione_en`,`i`.`uri` AS `immagine` from (`autori` `a` join `immagine` `i`) where (`i`.`id` = `a`.`immagine`)";
if ($data = DB_Manager::getInstance()->query($query)) {
    while ($row = $data->fetch_array(MYSQLI_ASSOC)) {
        $myTemplate->setBodyContentString("nomecompleto", $row['nomecompleto']);
        $myTemplate->setBodyContentString("nome", $row['nome']);
        $myTemplate->setBodyContentString("email", $row['email']);
        $myTemplate->setBodyContentString("telefono", $row['telefono']);
        $myTemplate->setBodyContentString("skype", $row['skype']);
        $myTemplate->setBodyContentString("facebook", $row['facebook']);
        $myTemplate->setBodyContentString("twitter", $row['twitter']);
        if (getLanguage() == 'en') {
            $descrizione = $row['descrizione_en'];
        } else {
            $descrizione = $row['descrizione'];
        }
        $letter_one=substr ($descrizione, 0 ,1 );
        $descrizione=substr ($descrizione, 1 ,-1 );
        $myTemplate->setBodyContentString( "prima_lettera", $letter_one);
        $myTemplate->setBodyContentString( "descrizione", $descrizione);
        $myTemplate->setBodyContentImage("immagine", $row['immagine']);
    }
} else {
    redirect($page = "index");
}
$prefix = "/";
if (getLanguage() == 'en') {
    $prefix = "/en/";
}
$myTemplate->setCanonicalUrl($prefix . "autori/");
$myTemplate->setBodyContentString("nav_message", L::nav_message);
$myTemplate->setBodyContentString("nav_home", L::nav_home);
$myTemplate->setBodyContentString("nav_page", L::messages_authors_nav_page);
$myTemplate->setBodyContentString("info", L::messages_authors_info);
$myTemplate->setBodyContentString("phone", L::messages_authors_phone);